package com.cans.lightning;

import com.cans.lightning.business.core.service.UUIDAutoGen;
import com.cans.lightning.business.core.utils.ContextUtil;
import org.beetl.sql.core.SQLManager;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.scheduling.annotation.EnableAsync;

import javax.annotation.Resource;

/**
 * @author 31733
 */
@EnableAsync
@SpringBootApplication
public class LightningApplication implements ApplicationRunner {

    @Resource
    private SQLManager sqlManager;
    @Resource
    private UUIDAutoGen idAutoGen;

    public static void main(String[] args) {
        ConfigurableApplicationContext ac = SpringApplication.run(LightningApplication.class, args);
        ContextUtil.setApplicationContext(ac);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        sqlManager.addIdAutoGen("uuid", idAutoGen);
    }
}
